package com.yj.provider.i18n;

import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

@Component
public class I18nService {

    private final MessageSource messageSource;

    public I18nService(MessageSource messageSource) {
        this.messageSource = messageSource;
    }

    public String getMessage(String msgKey){
        return messageSource.getMessage(msgKey,null, LocaleContextHolder.getLocale());
    }

    public String getMessage(String msgKey,Object ... objects){
        return messageSource.getMessage(msgKey,objects,LocaleContextHolder.getLocale());
    }

}
